import 'package:isar/isar.dart';
part 'medicine_model.g.dart';

@Collection()
class Medicine {
  Id? id;

  ///药品名称
  String? name;

  ///药品生产日期
  DateTime? productionDate;

  ///药品有效日期
  DateTime? expiryData;

  ///使用者
  String? user;

  ///使用对象
  @enumerated
  late Target target;

  ///用量
  int? dosage;

  ///单位
  @enumerated
  late DosageUnits unit;

  ///一天次数
  String? dailyFrequency;

  ///适应症
  String? indication;

  ///图片
  String? pic;

  Medicine({
    this.id,
    this.name,
    this.productionDate,
    this.expiryData,
    this.user,
    this.target=Target.adult, // 必须传入 target 参数
    this.dosage,
    this.unit=DosageUnits.ml,
    this.dailyFrequency,
    this.indication,
    this.pic,
  });


}

enum DosageUnits {
  ///毫升
  ml(0),

  ///片
  tab(1),

  ///滴
  gtt(2),

  ///匙
  tsp(3),

  ///喷
  puff(4);

  const DosageUnits(this.value);

  final int value;
}

enum Target {
  adult(0),
  child(1);

  const Target(this.value);

  final int value;
}
